package com.fenxiangtech.mall.service;

import com.fenxiangtech.mall.dto.OrderStatus;
import com.fenxiangtech.mall.dto.PageData;
import com.fenxiangtech.mall.dto.Result;
import com.fenxiangtech.mall.entity.Order;
import com.fenxiangtech.mall.entity.OrderProduct;
import com.fenxiangtech.mall.enums.OrderStatusEnum;

import java.util.List;

/**
 * @author zhangjiashun
 */
public interface OrderService {

    /**
     * 下单
     * @param orderProducts 订单商品列表
     * @return 订单商品状态
     */
    Result place(List<OrderProduct> orderProducts);

    /**
     * 检查订单是否属于当前用户
     * @param orderID
     * @return
     */
    boolean orderBelongCurrentUser(Long orderID);

    /**
     *
     * @param orderID
     * @return
     */
    Order getOrderByID(Long orderID);

    /**
     *
     * @param orderID
     * @return
     */
    int getOrderStatus(Long orderID);

    /**
     * 检查订单商品的库存是否充足
     * @param orderID
     * @return
     */
    OrderStatus checkOrderStock(Long orderID);

    /**
     *记录prepayID
     * @param prepayID
     * @param orderID
     * @return
     */
    boolean recordPrepayID(String prepayID, Long orderID);

    /**
     * 根据orderNo获取Order
     * @param orderNo
     * @return
     */
    Order getOrderByOrderNo(String orderNo);

    /**
     * 更新Order的状态
     * @param orderID
     * @param orderStatusEnum
     * @return
     */
    boolean updateOrderStatus(Long orderID, OrderStatusEnum orderStatusEnum);

    /**
     * 减库存
     * @param orderStatus
     * @return
     */
    boolean reduceStock(OrderStatus orderStatus);

    /**
     *
     * @param page
     * @param size
     * @return
     */
    PageData<Order> getOrderByUser(Integer page, Integer size);

    /**
     *
     * @param page
     * @param size
     * @return
     */
    PageData<Order> listOrder(Integer page, Integer size);

    /**
     * 发货
     * @param id
     * @return
     */
    Result<Order> delivery(Long id);
}
